#include "StdAfx.h"
#include "Player.h"
#include "../GameDefine/MsgHandle.h"
#include "GDlgMgr.h"
#include "GMainDlg.h"
#include "GLoginDlg.h"

Player	sLocalPlayer;
Player::Player(void)
{

}

void Player::Init()
{
	RegisterMessageHandle();
}

Player* Player::GetLocalPlayer()
{
	return &sLocalPlayer;
}
Player::~Player(void)
{
}

void Player::RegisterMessageHandle()
{
	REGISTER_WORLD_MSG(NS_PlayerAuthSession, *this, Player, &Player::HandleAuthSession)
}

DWORD Player::HandleAuthSession(LPVOID lp)
{
	MSGTRANSLATE(p, lp, NS_PlayerAuthSession);
	if (p->dwResult == EAS_Sucessed)
	{
		GMainDlg* pMainDlg = (GMainDlg*)GDlgMgr::Inst().GetDlg(_T("GMainDlg"));
		GLoginDlg* pLoginDlg = (GLoginDlg*)GDlgMgr::Inst().GetDlg(_T("GLoginDlg"));
		pMainDlg->SetActivated(TRUE);
		pLoginDlg->SetActivated(FALSE);
	}
	return 0;
}